home *** CD-ROM | disk | FTP | other *** search
- /* $Revision Header built automatically *************** (do not edit) ************
- **
- ** © Copyright by Dirk Federlein
- **
- ** File : Work:programming/dfa/Sourcen_V2.3/Datatypes/dfadt_libinit.c
- ** Created on : Dienstag, 14.03.95 15:08:08
- ** Created by : Dirk Federlein
- ** Current revision : V1.0
- **
- **
- ** Purpose
- ** -------
- ** Inits the datatype class
- **
- ** Revision V1.0
- ** --------------
- ** created on Dienstag, 14.03.95 15:08:08 by Dirk Federlein. LogMessage :
- ** --- Initial release ---
- **
- *********************************************************************************/
-
- #include "all_includes.h"
- #include "dfadt.h"
-
- #include "dfa.datatype_rev.h"
-
- char version[] = VERSTAG;
-
- struct Library * __asm __saveds LibInit(register __a0 BPTR Segment, register __d0 struct Library *Base);
- struct Library * __asm __saveds LibOpen(register __a6 struct Library *Base);
- BPTR __asm __saveds LibExpunge(register __a6 struct Library *Base);
- BPTR __asm __saveds LibClose(register __a6 struct Library *Base);
- LONG __asm __saveds LibNull(register __a6 struct Library *Base);
-
- Class * __saveds GetClassEngine(VOID);
-
- BPTR LibSegment = NULL;
- UBYTE __aligned LibName[] = "dfa.datatype";
- UBYTE __aligned LibID[] = VSTRING;
-
-
- struct ExecBase * SysBase;
- struct DosLibrary * DOSBase;
- struct IntuitionBase * IntuitionBase;
- struct GfxBase * GfxBase;
- struct Library * LayersBase,
- * UtilityBase,
- * DataTypesBase,
- * SuperClassBase;
-
- Class * TextClass;
-
- struct SignalSemaphore LockSemaphore;
-
-
- APTR LibVectors[] = /* die Sprungtabelle */
- {
- LibOpen,
- LibClose,
- LibExpunge,
- LibNull,
- GetClassEngine,
- (APTR)-1
- };
-
- struct
- {
- ULONG DataSize;
- APTR Table;
- APTR Data;
- struct Library * (*Init)();
- } __aligned LibInitTab =
- {
- sizeof(struct Library),
- LibVectors,
- NULL,
- LibInit
- };
-
- struct Library * __asm __saveds
- LibInit(register __a0 BPTR Segment,register __d0 struct Library *Base)
- {
-
- Base -> lib_Node . ln_Type = NT_LIBRARY;
- Base -> lib_Node . ln_Name = LibName;
- Base -> lib_Flags = LIBF_CHANGED | LIBF_SUMUSED;
- Base -> lib_Version = VERSION;
- Base -> lib_Revision = REVISION;
- Base -> lib_IdString = LibID;
-
- LibSegment = Segment;
- SysBase = *(struct ExecBase **)4;
- InitSemaphore(&LockSemaphore);
-
-
- return(Base);
- }
-
-
- struct Library * __asm __saveds
- LibOpen(register __a6 struct Library *Base)
- {
- Base -> lib_OpenCnt++;
- Base -> lib_Flags &= ~LIBF_DELEXP;
-
-
- if(Base -> lib_OpenCnt == 1)
- {
- ObtainSemaphore(&LockSemaphore);
-
- if(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",37))
- {
- if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37))
- {
- if(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",39))
- {
- if(UtilityBase = OpenLibrary("utility.library",0))
- {
- if(LayersBase = OpenLibrary("layers.library",0))
- {
- if(DataTypesBase = OpenLibrary("datatypes.library",0))
- {
- if(SuperClassBase = OpenLibrary("datatypes/text.datatype",0))
- {
- if(TextClass = MakeClass("dfa.datatype", TEXTDTCLASS,NULL,sizeof(struct DDTData),NULL))
- {
- extern ULONG ClassDispatch();
-
-
- TextClass->cl_Dispatcher.h_Entry = (HOOKFUNC)ClassDispatch;
- TextClass->cl_UserData = (ULONG) Base;
- AddClass(TextClass);
- ReleaseSemaphore(&LockSemaphore);
- return(Base);
- }
-
- CloseLibrary(SuperClassBase);
- SuperClassBase = NULL;
- }
- CloseLibrary(DataTypesBase);
- DataTypesBase = NULL;
- }
- CloseLibrary(LayersBase);
- LayersBase = NULL;
- }
- CloseLibrary(UtilityBase);
- UtilityBase = NULL;
- }
- CloseLibrary(GfxBase);
- GfxBase = NULL;
- }
- CloseLibrary(IntuitionBase);
- IntuitionBase = NULL;
- }
- CloseLibrary(DOSBase);
- DOSBase = NULL;
- }
-
- ReleaseSemaphore(&LockSemaphore);
- return(NULL);
-
- }
- else
- return(Base);
- }
-
- BPTR __asm __saveds LibExpunge(register __a6 struct Library *Base)
- {
- BPTR TempSegment = LibSegment;
-
-
- if(!Base -> lib_OpenCnt && TempSegment)
- {
- Remove((struct Node *)Base);
- FreeMem((BYTE *)Base - Base -> lib_NegSize, Base -> lib_NegSize + Base -> lib_PosSize);
- LibSegment = NULL;
- return(TempSegment);
- }
- else
- {
- Base -> lib_Flags |= ~LIBF_DELEXP;
- return(NULL);
- }
- }
-
- BPTR __asm __saveds LibClose(register __a6 struct Library *Base)
- {
-
- if(!(Base -> lib_OpenCnt--))
- Base -> lib_OpenCnt = 0;
-
-
- if(!Base -> lib_OpenCnt)
- {
- ObtainSemaphore(&LockSemaphore);
-
- if(TextClass)
- {
- RemoveClass(TextClass);
- FreeClass(TextClass);
- TextClass = NULL;
- }
-
- CloseLibrary(SuperClassBase);
- SuperClassBase = NULL;
-
- CloseLibrary(DataTypesBase);
- DataTypesBase = NULL;
-
- CloseLibrary(LayersBase);
- LayersBase = NULL;
-
- CloseLibrary(UtilityBase);
- UtilityBase = NULL;
-
- CloseLibrary(IntuitionBase);
- IntuitionBase = NULL;
-
- CloseLibrary(GfxBase);
- GfxBase = NULL;
-
- CloseLibrary(DOSBase);
- DOSBase = NULL;
-
- ReleaseSemaphore(&LockSemaphore);
- }
-
- if((Base -> lib_Flags & LIBF_DELEXP) && !Base -> lib_OpenCnt)
- return(LibExpunge(Base));
-
- return(NULL);
- }
-
- LONG __asm __saveds
- LibNull(register __a6 struct Library *Base)
- {
-
- return(NULL);
- }
-
- Class * __saveds GetClassEngine()
- {
- Class *class;
-
- ObtainSemaphore(&LockSemaphore);
-
- class = TextClass;
-
- ReleaseSemaphore(&LockSemaphore);
-
- return(class);
-
-
- }
-
-